#ifdef WX_PRECOMP
#include "wx_pch.h"
#endif

#include <wx/wx.h>
#include "MainFrame.h"

//helper functions
wxString wxbuildinfo( wxbuildinfoformat format ) {
	wxString wxbuild( wxVERSION_STRING );
	if( format == long_f ) {
#if defined(m__WXMSW__)
		wxbuild << _T( "-Windows" );
#elif defined(m__WXMAC__)
		wxbuild << _T( "-Mac" );
#elif defined(m__UNIX__)
		wxbuild << _T( "-Linux" );
#endif

#if wxUSE_UNICODE
		wxbuild << _T( "-Unicode build" );
#else
		wxbuild << _T( "-ANSI build" );
#endif // wxUSE_UNICODE
	}

	return wxbuild;
}

MainFrame::MainFrame( wxFrame *frame ) :
	BaseMainFrame( frame ),
	m_document( 0 ),
	m_tool( 0 )
{
#if wxUSE_STATUSBAR
	statusBar->SetStatusText( _( "Hello Code::Blocks user!" ), 0 );
	statusBar->SetStatusText( wxbuildinfo( short_f ), 1 );
#endif
	m_propertyGridEntityViewer = new PropertyGridEntityViewer( m_propertyGrid );

	m_openFileDialog = new wxFileDialog( this, wxT( "Open file" ), wxT( "" ), wxT( "" ), wxT( "*.*" ), wxFD_OPEN | wxFD_FILE_MUST_EXIST );
	m_saveFileDialog = new wxFileDialog( this, wxT( "Save file" ), wxT( "" ), wxT( "" ), wxT( "*.*" ), wxFD_SAVE | wxFD_OVERWRITE_PROMPT );

	m_mainMenu->Enable( MAIN_MENU_FILE_SAVE, false );
	m_mainMenu->Enable( MAIN_MENU_FILE_SAVE_AS, false );
	m_mainMenu->Enable( MAIN_MENU_FILE_CLOSE, false );
	m_mainMenu->Enable( MAIN_MENU_EDIT_UNDO, false );
	m_mainMenu->Enable( MAIN_MENU_EDIT_REDO, false );
	m_mainMenu->Enable( MAIN_MENU_EDIT_CUT, false );
	m_mainMenu->Enable( MAIN_MENU_EDIT_COPY, false );
	m_mainMenu->Enable( MAIN_MENU_EDIT_PASTE, false );
	m_mainMenu->Enable( MAIN_MENU_EDIT_DELETE, false );

	m_toolBarMain->EnableTool( MAIN_TOOLBAR_SAVE, false );
	m_toolBarMain->EnableTool( MAIN_TOOLBAR_UNDO, false );
	m_toolBarMain->EnableTool( MAIN_TOOLBAR_REDO, false );
	m_toolBarMain->EnableTool( MAIN_TOOLBAR_CUT, false );
	m_toolBarMain->EnableTool( MAIN_TOOLBAR_COPY, false );
	m_toolBarMain->EnableTool( MAIN_TOOLBAR_PASTE, false );
	m_toolBarMain->EnableTool( MAIN_TOOLBAR_DELETE, false );

	m_workFieldPanel->SetDoubleBuffered( true );

	wxSize workFieldPanelSize = m_workFieldPanel->GetSize();
	m_coordsTransformer.Resize( workFieldPanelSize.GetWidth(), workFieldPanelSize.GetHeight() );
	m_coordsTransformer.SetCamera( cmn::Transform( cmn::Vec2::Zero(), 0.0f, 5.0f ) );
}

MainFrame::~MainFrame() {
	delete m_saveFileDialog;
	delete m_openFileDialog;

	delete m_propertyGridEntityViewer;
	delete m_tool;
	delete m_document;
}

